package com.baizhi.service.impl;

import com.baizhi.entity.CmfzBanner;
import com.baizhi.mapper.CmfzBannerMapper;
import com.baizhi.service.CmfzBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ljh
 * @since 2020-08-18
 */
@Service
public class CmfzBannerServiceImpl extends ServiceImpl<CmfzBannerMapper, CmfzBanner> implements CmfzBannerService {

    /**
     * 分页查询
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageInfo<CmfzBanner> selectAllBannerByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<CmfzBanner> cmfzBanners = baseMapper.selectList(null);
        return new PageInfo<>(cmfzBanners);
    }


    /**
     * 逻辑删除
     * @param id
     */
    @Override
    public void deleteBanner(Integer id) {
        baseMapper.deleteById(id);
    }

    /**
     * 新增banner
     * @param cmfzBanner
     */
    @Override
    public void addBanner(CmfzBanner cmfzBanner) {
        baseMapper.insert(cmfzBanner);
    }

    /**
     * 修改banner
     * @param cmfzBanner
     */
    @Override
    public void updateBanner(CmfzBanner cmfzBanner) {
        baseMapper.updateById(cmfzBanner);
    }
}
